package com.yshkj.payment.dto;

import com.yshkj.payment.entity.medicinal.Medicinal;
import com.yshkj.payment.entity.medicinal.Spec;
import com.yshkj.payment.utils.DateUtils;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by 唐旭 on 2016/10/2.
 */
@Data
public class MedicinalDto {
    private String uuid;
    //药品名称
    private String name;

    //生产厂家
    private ProducerDto producer;

    private List<SpecDto> specList = new ArrayList<>();

    private String createDateTime;

    public MedicinalDto() {
    }

    public MedicinalDto(Medicinal item) {
        this.uuid = item.getUuid();
        this.name = item.getName();
        if (item.getProducer() != null) {
            this.producer = new ProducerDto(item.getProducer());
        }
        for (Spec spec : item.getSpecList()) {
            specList.add(new SpecDto(spec));
        }
        this.createDateTime = DateUtils.toDateText(item.getCreateDateTime(), DateUtils.DEFAULT_DATE_TIME_FORMAT);
    }
}
